$(document).ready(function () {
    App.init();
    TableManageFixedHeader.init();

    FormWizardValidation.init();
    FormWizardValidation2.init();

    $('.datepicker-default').datepicker({
        language: 'zh-CN',//显示中文
        format: 'yyyy-mm-dd',//显示格式
        minView: "month",//设置只显示到月份
        initialDate: new Date(),//初始化当前日期
        autoclose: true,//选中自动关闭
        todayBtn: 'linked'//显示今日按钮
    });


});



function viewPage(url) {
    window.open(url);


}


function deleteFile(tid) {


    $("#showSubInfo").html("确认删除？");
    $("#modal-subInfo").modal('show');

    $("#subButtonYes").click(function() {

        var url = '/attachment/delete/' + tid;
        $.get(url, function(data) {
            if (data.success) {
                location.reload();
            }
        });
    });




    window.ParsleyValidator.addValidator('companyname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('creditcode', function(value) {
        if(value!= ""){
            return /[A-Z0-9]{18}/g.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('legalpersonname', function(value) {
        if(value!= ""){
            return /^[\u0391-\uFFE5A-Za-z]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('legalpersonidno', function(value) {
        if(value!= ""){
            return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value);
        }
        return true;
    },32);
    window.ParsleyValidator.addValidator('legalpersonmobile', function(value) {
        if(value!= ""){
            return /^1\d{10}$/.test(value);
        }
        return true;
    },32);
    window.ParsleyValidator.addValidator('telephone', function(value) {
        if(value!= ""){
            var b = value.length;
            return (b == 11 &&  /^1\d{10}$/.test(value)) || (b >= 10 && b <= 13 && /^0\d{2}-\d+$/.test(value))
                || (b >= 10 && b <= 13 && /^0\d{3}-\d+$/.test(value) || (b >= 10 && b <= 13 && /^0\d{2}\d+$/.test(value)));
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('only',function (jobNumber){
        var result = true;
        if(jobNumber!="" && jobNumber!=null){
            $.ajax({
                type:"post",
                url:"/channel/onlyJobNumber",
                async:false,
                data:{jobNumber:jobNumber},
                success:function (msg){
                    if(msg.success!=true){
                        result = false;
                    }
                }
            });
        }
        return result;
    },32);

    window.ParsleyValidator.addValidator('jobnumber', function(value) {
        if(value!= ""){
            return /^[0-9a-zA-Z]*$/g.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('contactcompanyname', function(value) {
        if(value!= ""){
            return /^[A-Za-z0-9\u4e00-\u9fa5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('accountname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z\u4e00-\u9fa5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('accountno', function(value) {
        if(value!= ""){
            return /^[0-9]*$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('bankname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('bankbranchname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('alipayno', function(value) {
        if(value!= ""){
            return( /^[a-zA-Z0-9]+$/.test(value) || /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(value)) ;
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('wechatno', function(value) {
        if(value!= ""){
            return (/^[a-zA-Z][a-zA-Z0-9_-]{5,19}$/.test(value)|| /^[a-zA-Z0-9]+$/.test(value));
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('filetype', function(value) {
        if(value!= ""){
            return /\.(jpg|pdf|png|doc|docx|JPG|PDF|PNG|DOC|DOCX)$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('homeaddress', function(value) {
        if(value!= ""){
            return /^[\u4E00-\u9FA5A-Za-z\d\-]+$/.test(value);
        }
        return true;
    },32);

}